package org.xteam.sled.semantic.exp;

import org.xteam.parser.runtime.Span;
import org.xteam.sled.semantic.IEvaluationContext;

public abstract class Exp {

	private Exp parent;

	public abstract void visit(IExpVisitor visitor);
	
	public boolean isConst() {
		return false;
	}

	public TermList toTermList() {
		return toTermList(false);
	}
	
	private TermList toTermList(boolean neg) {
		return toTermList(neg, new TermList());
	}

	protected TermList toTermList(boolean neg, TermList answers) {
		answers.add(neg ? -1 : 1, this);
		return answers;
	}
	
	public Exp parent() {
		return parent;
	}
	
	public void setParent(Exp parent) {
		this.parent = parent;
	}

	public Exp insistSingle(IEvaluationContext context, Span span) {
		// XXX should be completed to ensure that expression is not generative
		// context.reportError(span, "generating expression not permitted");
		return this;
	}

	public Exp superSymplify() {
		System.err.println("Exp.superSymplify: not implemented");
		return this;
	}

	public Integer unConst() {
		return null;
	}
	
}
